package two.dimensional.arrays;

/**
 * @author shkstart
 * @date 2022/4/18 - 22:30
 */
public class ArrayExceptionTest {
    public static void main(String[] args) {
        //1. 数组角标越界的异常：ArrayIndexOutOfBoundsExcetion

        int arr[] = new int[]{1,2,3,4,5,6};

//        for (int i = 0; i <= arr.length; i++ ) {
//            System.out.println(arr[i]);
//        }

//        System.out.println(arr[-2]);

//        System.out.println("hello");

        //2.2. 空指针异常：NullPointerException
//        情况1：
//        int arr1[] = new int[]{1,2,3};
//        arr1[0] = null;
//        System.out.println(arr[0]);

//        情况2:
//        int[][] arr2 = new int[4][];
//        System.out.println(arr2[3][0]);

//        情况3：
        String arr3[] = new String[]{"AA","BB","CC"};
        arr3[0] = null;
        System.out.println(arr3[0].toString());

    }
}
